package com.mogist.hqc.module.product.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.mogist.hqc.R
import com.mogist.hqc.entitys.response.ProductDetailVo
import com.mogist.hqc.util.Util
import talex.zsw.basecore.util.RegTool
import talex.zsw.basecore.util.TimeTool

/**
 * 作者：赵小白 email:vvtale@gmail.com  
 * 修改人：
 * 修改时间：
 * 修改备注：
 */
class ProductDayAdapter(val price: String) : BaseQuickAdapter<ProductDetailVo.ProductDailyPriceListEntity, BaseViewHolder>(
        R.layout.item_product_day)
{
    override fun convert(helper: BaseViewHolder, item: ProductDetailVo.ProductDailyPriceListEntity)
    { // iTvDate iTvPrice
        if (RegTool.isNotEmpty(item.adultPrice))
        {
            helper.setText(R.id.iTvPrice, "￥${item.adultPrice}")
        }
        else if (RegTool.isNotEmpty(item.childPrice))
        {
            helper.setText(R.id.iTvPrice, "￥${item.childPrice}")
        }
        else
        {
            helper.setText(R.id.iTvPrice, "￥$price")
        }

        try
        {
            helper.setText(R.id.iTvDate,
                           TimeTool.changeFormat(item.saleDate,
                                                 "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
                                                 "MM-dd  EEEE"))
        }
        catch (e: Exception)
        {
            helper.setText(R.id.iTvDate, Util.getTimeStr(item.saleDate))
            e.printStackTrace()
        }
    }
}